package com.yt.al.util;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class WaitUtil {
	private static final int _stepTimeout = 5;

	public static WebElement waitUtil(WebDriver driver, By by)
    {
		WebElement ele = null;
		for (int i = 0; i < _stepTimeout; i++)
        {
            try
            {
            	ele = driver.findElement(by);
            }
            catch (Exception e)
            {
               WriteLogUtil.writeMsgToFile(i+"鎵撳嵃鍏冪礌ele锛�"+"绛夊緟鏂规硶瀹氫綅鍏冪礌澶辫触");
               TestUtil.waits(1000);
            }
        }
		return ele;
       
    }
	/**
	 * 
	 * @param by
	 * @return
	 */
	public static List<WebElement> waitUtils(WebDriver driver, By by)
    {	
		List<WebElement> list = null;
		for (int i = 0; i < _stepTimeout; i++)
        {
            try
            {
            	list = driver.findElements(by);
            }
            catch (Exception e)
            {
               TestUtil.waits(1000);
            }
        }
        return list;
    }

}
